package com.sx.art2.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sx.art2.beans.Art;
import com.sx.art2.beans.AuctionInfo;
import com.sx.art2.mapper.ArtMapper;
import com.sx.art2.mapper.AuctionInfoMapper;
import com.sx.art2.service.ArtService;

@Service
public class ArtServiceImpl implements ArtService {

	@Autowired
	ArtMapper artMapper;
	@Autowired
	AuctionInfoMapper auctionInfoMapper;
	
	@Override
	public void insert(Art art) {
		// TODO 自动生成的方法存根
		artMapper.insert(art);		
	}

	@Override
	public List<Art> list() {
		// TODO 自动生成的方法存根
		return artMapper.list();
	}

	@Override
	public Art getArt(int artId) {
		// TODO 自动生成的方法存根
		return artMapper.selectById(artId);
	}

	@Transactional
	@Override
	public void addAuction(String pic,AuctionInfo auctionInfo) {
		// TODO 自动生成的方法存根
		artMapper.addAcution(auctionInfo.getArtId(),pic);
		auctionInfoMapper.insert(auctionInfo);
	}

	@Override
	public Art lookArt(int artId) {
		// TODO 自动生成的方法存根
		return artMapper.lookArt2(artId);
	}

	@Override
	public List<Art> selectAllArt(Art art) {
		// TODO Auto-generated method stub
		return artMapper.selectAllArt(art);
	}
	public int selectByName(String artName) {
		    Art c = artMapper.selectByName(artName);
		return c.getArtId();
	}

	@Override
	public List<Art> Alist(int artState) {
		// TODO Auto-generated method stub
		return artMapper.Alist(artState);
	}

/*	@Override
	public void updateAuctionState(int auctionState) {
		// TODO 自动生成的方法存根
		artMapper.updateAuctionState(auctionState);
		
	}*/

}
